import { Toast, MessageBox } from 'mint-ui';

export default {
  name: 'login',
  data() {
    return {
      form: {
        username: '',
        password: ''
      }
    }
  },
  methods: {
    // 处理登录
    handleLogin() {
      let {username, password} = this.form;
      if(!username) {
        Toast({
          message: '手机号没有填写',
          className: 'zh-toast',
          iconClass: 'fa fa-warning',
          duration: 9000
        });
        return;
      }
      if(!password) {
        Toast({
          message: '密码没有填写',
          className: 'zh-toast',
          iconClass: 'fa fa-warning'
        });
        return;
      }
      // 参数处理
      let params = {
        username,
        password
      };
      // 请求
      this.$axios.post('/xxx/login/in', params).then(res => {
        if(res.status) {
          Toast({
            message: res.message,
            className: 'zh-toast',
            iconClass: 'fa fa-check',
            duration: 1000
          });
        } else {
          Toast({
            message: res.message,
            className: 'zh-toast',
            iconClass: 'fa fa-warning'
          });
        }
      });
    }
  }
}